package com.example.iot.controller;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.example.iot.entity.AlarmInfo;
import com.example.iot.entity.PatchUpgrade;
import com.example.iot.service.impl.AlarmInfoServiceImpl;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Component;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/alarminfo")
@RequiredArgsConstructor
@Component
public class AlarmInfoController {
    private final AlarmInfoServiceImpl alarmInfoService;
    @PostMapping("/addinfo")
    public boolean addInfo (@RequestBody AlarmInfo alarmInfo) {
        boolean re=alarmInfoService.save(alarmInfo);
        return re;
    }
    @GetMapping("/selectAll")
    public List<AlarmInfo> selectAll (String deviceId) {
        QueryWrapper<AlarmInfo> queryWrapper =  new QueryWrapper<>();
        queryWrapper.eq("deviceId",deviceId);
        List<AlarmInfo> list=alarmInfoService.getBaseMapper().selectList(queryWrapper);
        return list;
    }
}
